<!DOCTYPE HTML>
<html>
<head>
<title>WinSetTitle | AutoHotkey</title>
<meta name="description" content="The WinSetTitle command changes the title of the specified window." />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>WinSetTitle</h1>

<p>改变指定窗口的标题.</p>

<pre class="Syntax">
<span class="func">WinSetTitle</span>, NewTitle
<span class="func">WinSetTitle</span>, WinTitle, WinText, NewTitle <span class="optional">, ExcludeTitle, ExcludeText</span>
</pre>
<h2>参数</h2>
<dl>

  <dt>NewTitle</dt>
  <dd><p>窗口的新标题. 如果只给出此参数, 那么使用<a href="../misc/WinTitle.htm#LastFoundWindow">上次找到的窗口</a>.</p></dd>

  <dt>WinTitle</dt>
  <dd><p>窗口标题或识别目标窗口的其他条件. 请参阅 <a href="../misc/WinTitle.htm">WinTitle</a>.</p></dd>

  <dt>WinText</dt>
  <dd><p>如果使用此参数, 那么它必须是目标窗口中单个文本元素的子字符串(和内置的 Window Spy 工具显示的一样). 当 <a href="DetectHiddenText.htm">DetectHiddenText</a> 的设置为 ON 时, 那么会检测到隐藏文本元素.</p></dd>

  <dt>ExcludeTitle</dt>
  <dd><p>标题中含有此参数值的窗口将被排除.</p></dd>

  <dt>ExcludeText</dt>
  <dd><p>文本中含有此参数值的窗口将被排除.</p></dd>

</dl>

<h2>备注</h2>
<p>如果窗口所在的程序经常改变窗口的标题, 那么此命令对标题的修改只是暂时的.</p>
<p>窗口标题和文本是区分大小写的. 只有在打开 <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> 设置时, 才能检测到隐藏窗口.</p>
<h2>相关</h2>
<p><a href="WinMove.htm">WinMove</a>, <a href="WinGetActiveStats.htm">WinGetActiveStats</a>, <a href="WinGetActiveTitle.htm">WinGetActiveTitle</a>, <a href="WinGetText.htm">WinGetText</a>, <a href="ControlGetText.htm">ControlGetText</a>, <a href="WinGetPos.htm">WinGetPos</a>, <a href="WinSet.htm">WinSet</a></p>
<h2>示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>WinSetTitle, Untitled - Notepad, , This is a new title
</div>

<div class="ex" id="ExLastFound">
<p><a href="#ExLastFound">#2</a>: 使用最后找到的窗口的替代方法:</p>
<pre>Run, notepad.exe
WinWaitActive, Untitled - Notepad
WinSetTitle, This is a new title  <em>; 使用前面 WinWaitActive 找到的窗口</em></pre>
</div>

</body>
</html>